<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/dute_favicon_32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/dute_favicon_16x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">
  <link rel="manifest" href="/images/manifest.json">
  <meta name="msapplication-config" content="/images/browserconfig.xml">
  <meta http-equiv="Cache-Control" content="no-transform">
  <meta http-equiv="Cache-Control" content="no-siteapp">
  <meta name="google-site-verification" content="mpI5dkydstZXl6UcDCppqktXK0bbvqdZ6LkZ3KNk4Iw">
  <meta name="baidu-site-verification" content="code-a1LksZX2Ds">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"whitestore.top","root":"/","scheme":"Gemini","version":"7.8.0","exturl":true,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="《Spring 实战》解读">
<meta property="og:type" content="article">
<meta property="og:title" content="《Spring 实战》解读">
<meta property="og:url" content="https://whitestore.top/2020/07/26/note2/index.html">
<meta property="og:site_name" content="爱看书的阿东">
<meta property="og:description" content="《Spring 实战》解读">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://raw.githubusercontent.com/lazyTimes/imageRepository/master/img/20200213191203.png?ynotemdtimestamp=1595748679079">
<meta property="og:image" content="https://raw.githubusercontent.com/lazyTimes/imageRepository/master/img/20200213191506.png?ynotemdtimestamp=1595748679079">
<meta property="article:published_time" content="2020-07-26T09:33:41.000Z">
<meta property="article:modified_time" content="2023-07-16T06:28:09.233Z">
<meta property="article:author" content="阿东">
<meta property="article:tag" content="《Spring 实战》解读">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://raw.githubusercontent.com/lazyTimes/imageRepository/master/img/20200213191203.png?ynotemdtimestamp=1595748679079">

<link rel="canonical" href="https://whitestore.top/2020/07/26/note2/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>《Spring 实战》解读 | 爱看书的阿东</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="爱看书的阿东" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">爱看书的阿东</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">赐他一块白色石头，石头上写着新名</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-sitemap">

    <a href="/sitemap.xml" rel="section"><i class="fa fa-fw fa-sitemap"></i>站点地图</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    

  <span class="exturl github-corner" data-url="aHR0cHM6Ly9naXRodWIuY29tL2xhenlUaW1lcw==" title="Follow me on GitHub" aria-label="Follow me on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></span>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2020/07/26/note2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          《Spring 实战》解读
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-07-26 17:33:41" itemprop="dateCreated datePublished" datetime="2020-07-26T17:33:41+08:00">2020-07-26</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-07-16 14:28:09" itemprop="dateModified" datetime="2023-07-16T14:28:09+08:00">2023-07-16</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/" itemprop="url" rel="index"><span itemprop="name">读书笔记</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2020/07/26/note2/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2020/07/26/note2/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>3.4k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>
            <div class="post-description">《Spring 实战》解读</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="《Spring-实战》解读"><a href="#《Spring-实战》解读" class="headerlink" title="《Spring 实战》解读"></a>《Spring 实战》解读</h1><h2 id="基本概念"><a href="#基本概念" class="headerlink" title="基本概念"></a>基本概念</h2><p>DI：依赖反转</p>
<p>AOP：切面编程</p>
<a id="more"></a>

<h3 id="Spring应用上下文"><a href="#Spring应用上下文" class="headerlink" title="Spring应用上下文"></a>Spring应用上下文</h3><p><strong>AnnotationConfigApplicationContext</strong> ：从一个或多个基于 Java 的配置类中加载 Spring 应用上下文。</p>
<p><strong>AnnotationConfigWebApplicationContext</strong> ：从一个或多个基于 Java 的配置类中加载 Spring Web 应用上下文。</p>
<p><strong>ClassPathXmlApplicationContext</strong> ：从类路径下的一个或多个 XML 配置文件中加载上下文定义，把应用上下文的定义文件作为类资源。</p>
<p><strong>FileSystemXmlapplicationcontext</strong> ：从文件系统下的一个或多个 XML 配置文件中加载上下文定义。</p>
<p><strong>XmlWebApplicationContext</strong> ：从 Web 应用下的一个或多个 XML 配置文件中加载上下文定义。</p>
<h3 id="Spring的生命周期"><a href="#Spring的生命周期" class="headerlink" title="Spring的生命周期"></a>Spring的生命周期</h3><p><img src="https://raw.githubusercontent.com/lazyTimes/imageRepository/master/img/20200213191203.png?ynotemdtimestamp=1595748679079" alt="Spring生命周期"></p>
<ol>
<li>Spring 对 bean 进行实例化；</li>
<li>Spring 将值和 bean 的引用注入到 bean 对应的属性中；</li>
<li>如果 bean 实现了 BeanNameAware 接口， Spring 将 bean 的 ID 传递给 setBean-Name() 方法；</li>
<li>如果 bean 实现了 BeanFactoryAware 接口， Spring 将调用 setBeanFactory() 方法，将 BeanFactory 容器实例传入；</li>
<li>如果 bean 实现了 ApplicationContextAware 接口， Spring 将调用 setApplicationContext() 方法，将 bean 所在的应用上下文的引用传入进来；</li>
<li>如果 bean 实现了 BeanPostProcessor 接口， Spring 将调用它们的 post-ProcessBeforeInitialization() 方法；</li>
<li>如果 bean 实现了 InitializingBean 接口， Spring 将调用它们的 after-PropertiesSet() 方法。类似地，如果 bean 使用 init- method 声明了初始化方法，该方法也会被调用；</li>
<li>如果 bean 实现了 BeanPostProcessor 接口， Spring 将调用它们的 post-ProcessAfterInitialization() 方法；</li>
<li>此时， bean 已经准备就绪，可以被应用程序使用了，它们将一直驻留在应用上下文中，直到该应用上下文被销毁；</li>
<li>如果 bean 实现了 DisposableBean 接口， Spring 将调用它的 destroy() 接口方法。同样，如果 bean 使用 destroy-method 声明了销 毁方法，该方法也会被调用</li>
</ol>
<h3 id="Spring-模块-（4-0为例）"><a href="#Spring-模块-（4-0为例）" class="headerlink" title="Spring 模块 （4.0为例）"></a>Spring 模块 （4.0为例）</h3><p><img src="https://raw.githubusercontent.com/lazyTimes/imageRepository/master/img/20200213191506.png?ynotemdtimestamp=1595748679079" alt="Spring模块"></p>
<h3 id="版本新特性"><a href="#版本新特性" class="headerlink" title="版本新特性"></a>版本新特性</h3><p>3.1 ： 注解编程</p>
<p>3.2：增强SpringMVC，加入更多的支持</p>
<p>4.0：Websocket加入，JDK1.8的支持以及Lambada表达式</p>
<h2 id="Spring的Bean"><a href="#Spring的Bean" class="headerlink" title="Spring的Bean"></a>Spring的Bean</h2><h3 id="装配Bean的三种方式："><a href="#装配Bean的三种方式：" class="headerlink" title="装配Bean的三种方式："></a>装配Bean的三种方式：</h3><ol>
<li>自动装配（扫描）</li>
<li>XML装配</li>
<li>通过JAVA代码</li>
</ol>
<h3 id="自动装配"><a href="#自动装配" class="headerlink" title="自动装配"></a>自动装配</h3><blockquote>
<p>Q：<strong>为Bean命名有什么影响？</strong></p>
<p>A： <strong>@Inject</strong> 和 <strong>@Autowired</strong> 的注入会受到影响</p>
<p>Q：<strong>Bean默认的命名规则？</strong></p>
<p>A：类名的首字母小写</p>
<p>Q：除了@Bean定义名称之外的办法？</p>
<p>A：<strong>@Named</strong></p>
</blockquote>
<h3 id="JAVA配置"><a href="#JAVA配置" class="headerlink" title="JAVA配置"></a>JAVA配置</h3><p>需要注意Bean是单例的，如果引用对象也存在引用，那么对应的引用对象也是单利的</p>
<h3 id="XML配置"><a href="#XML配置" class="headerlink" title="XML配置"></a>XML配置</h3><ol>
<li>使用 <constructor-arg> 元素进行构造器参数的注入</li>
<li>由于xml 配置非常的繁琐，推荐Java配置</li>
</ol>
<h2 id="更高级的Bean装配"><a href="#更高级的Bean装配" class="headerlink" title="更高级的Bean装配"></a>更高级的Bean装配</h2><h3 id="profile-Bean"><a href="#profile-Bean" class="headerlink" title="profile Bean"></a>profile Bean</h3><p><code>@Profile</code> 注解指定某个 bean 属于哪一个 profile</p>
<blockquote>
<p>3.2之前：@profile只能作用于类</p>
</blockquote>
<h3 id="激活profile"><a href="#激活profile" class="headerlink" title="激活profile"></a>激活profile</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">spring.profiles.active&#96; 和 &#96;spring.profiles.default</span><br></pre></td></tr></table></figure>

<p>通常情况下会选择<code>dev</code></p>
<h3 id="条件化-Bean"><a href="#条件化-Bean" class="headerlink" title="条件化 Bean"></a>条件化 Bean</h3><p><strong>@Conditional</strong>：SpringBoot的核心</p>
<p>运作基本原理：</p>
<p>它通过给定的 <code>ConditionContext</code>对象进而得到<code>Environment</code>对象，并使用这个对象检查环境中是否存在名为 magic 的环境属性</p>
<blockquote>
<p>通过 ConditionContext ，我们可以做到如下几点：</p>
<ul>
<li>借助 <code>getRegistry()</code> 返回的 BeanDefinitionRegistry 检查 bean 定义；</li>
<li>借助 <code>getBeanFactory()</code>返回的 ConfigurableListableBeanFactory 检查 bean 是否存在，甚至探查 bean 的属性；</li>
<li>借助 <code>getEnvironment()</code> 返回的 Environment 检查环境变量是否存在以及它的值是什么；</li>
<li>读取并探查 <code>getResourceLoader()</code> 返回的 ResourceLoader 所加载的资源；</li>
<li>借助 <code>getClassLoader()</code>返回的 ClassLoader 加载并检查类是否存在。</li>
</ul>
</blockquote>
<h4 id="标示首选的-bean"><a href="#标示首选的-bean" class="headerlink" title="标示首选的 bean"></a>标示首选的 bean</h4><p><code>@Primary</code>：当自动装配Bean遇到歧义的时候可以设置首选Bean</p>
<h4 id="限定自动装配的-bean"><a href="#限定自动装配的-bean" class="headerlink" title="限定自动装配的 bean"></a>限定自动装配的 bean</h4><p><code>@Qualifier</code>：注解是使用限定符的主要方式</p>
<p>注意：另一种使用方式是定义一个注解然后使用限定装配符号实现自己标记</p>
<h2 id="Bean的作用域"><a href="#Bean的作用域" class="headerlink" title="Bean的作用域"></a>Bean的作用域</h2><p>单例（ Singleton ）：在整个应用中，只创建 bean 的一个实例。</p>
<p>原型（ Prototype ）：每次注入或者通过 Spring 应用上下文获取的时候，都会创建一个新的 bean 实例。</p>
<p>会话（ Session ）：在 Web 应用中，为每个会话创建一个 bean 实例。</p>
<p>请求（ Rquest ）：在 Web 应用中，为每个请求创建一个 bean 实例。</p>
<p>配置方式：<code>@Scope</code></p>
<p>注意在创建时候使用的是代理而不是真正的New 一个对象</p>
<h2 id="运行时注入"><a href="#运行时注入" class="headerlink" title="运行时注入"></a>运行时注入</h2><p>Spring提供了两种办法来实现属性注入</p>
<ul>
<li>属性占位符（ Property placeholder ）</li>
<li>Spring 表达式语言（ SpEL ）</li>
</ul>
<h1 id="SpringMVC"><a href="#SpringMVC" class="headerlink" title="SpringMVC"></a>SpringMVC</h1><h3 id="DispatcherServelet"><a href="#DispatcherServelet" class="headerlink" title="DispatcherServelet"></a>DispatcherServelet</h3><p>DispatcherServlet 是 Spring MVC 的核心。在这里请求会第一次接触到框架，它要负责将请求路由到其他的组件之中。</p>
<p><code>AbstractAnnotationConfigDispatcherServletInitializer</code>核心实现类</p>
<h2 id="Spring-Web-Flow"><a href="#Spring-Web-Flow" class="headerlink" title="Spring Web Flow"></a>Spring Web Flow</h2><h2 id="是什么："><a href="#是什么：" class="headerlink" title="是什么："></a>是什么：</h2><p>一种基于会话的流程式框架</p>
<h2 id="为什么会有web-Flow"><a href="#为什么会有web-Flow" class="headerlink" title="为什么会有web Flow"></a>为什么会有web Flow</h2><p>在解决web与用户的交互流程方面做了很大的帮助和改进，能够实现一种类似OA的流程式业务</p>
<h2 id="怎么做："><a href="#怎么做：" class="headerlink" title="怎么做："></a>怎么做：</h2><ol>
<li>看官网：<span class="exturl" data-url="aHR0cHM6Ly9wcm9qZWN0cy5zcHJpbmcuaW8vc3ByaW5nLXdlYmZsb3cv" title="https://projects.spring.io/spring-webflow/">https://projects.spring.io/spring-webflow/<i class="fa fa-external-link"></i></span></li>
<li>简书博客：<span class="exturl" data-url="aHR0cHM6Ly93d3cuamlhbnNodS5jb20vcC82YzQ0OTAyYThlNGU=" title="https://www.jianshu.com/p/6c44902a8e4e">https://www.jianshu.com/p/6c44902a8e4e<i class="fa fa-external-link"></i></span></li>
<li>对比：<span class="exturl" data-url="aHR0cHM6Ly93d3cuY25ibG9ncy5jb20vUGllcnMvcC82NTg4MjkwLmh0bWw=" title="https://www.cnblogs.com/Piers/p/6588290.html">https://www.cnblogs.com/Piers/p/6588290.html<i class="fa fa-external-link"></i></span></li>
</ol>
<h2 id="总结："><a href="#总结：" class="headerlink" title="总结："></a>总结：</h2><p>由于大量的XML配置已经不适合当前时代的发展了，还是建议使用MVC吧</p>
<p>某些一对一的服务下面可能会有奇效</p>
<h1 id="Spring-Security"><a href="#Spring-Security" class="headerlink" title="Spring Security"></a>Spring Security</h1><h2 id="是什么？"><a href="#是什么？" class="headerlink" title="是什么？"></a>是什么？</h2><p>保护web 应用程序的权限，以及保护程序安全的一个框架</p>
<h2 id="为什么？"><a href="#为什么？" class="headerlink" title="为什么？"></a>为什么？</h2><p>防止非法用户的攻击行为，对于用户的权限进行限定</p>
<h2 id="同类产品比较："><a href="#同类产品比较：" class="headerlink" title="同类产品比较："></a>同类产品比较：</h2><p><strong>Apach Shiro</strong>：Spring4 之后倾向于使用Apach Shiro的支持，因为该框架配置更加灵活，实现更加简单，最关键是不仅仅限制在Web框架！！！</p>
<h2 id="怎么做：-1"><a href="#怎么做：-1" class="headerlink" title="怎么做："></a>怎么做：</h2><ol>
<li>看官网：<span class="exturl" data-url="aHR0cHM6Ly9zcHJpbmcuaW8vcHJvamVjdHMvc3ByaW5nLXNlY3VyaXR5" title="https://spring.io/projects/spring-security">https://spring.io/projects/spring-security<i class="fa fa-external-link"></i></span></li>
<li>百度或者谷歌查看案例实战</li>
</ol>
<p>此框架只有遇到实际应用才能掌握，不做详细笔记</p>
<h2 id="注意事项："><a href="#注意事项：" class="headerlink" title="注意事项："></a>注意事项：</h2><ul>
<li>配置用户存储；</li>
<li>指定哪些请求需要认证，哪些请求不需要认证，以及所需要的权限；</li>
<li>提供一个自定义的登录页面，替代原来简单的默认登录页。</li>
</ul>
<h1 id="AMQP"><a href="#AMQP" class="headerlink" title="AMQP"></a>AMQP</h1><h2 id="是什么？-1"><a href="#是什么？-1" class="headerlink" title="是什么？"></a>是什么？</h2><p>一种新的消息通信协议，不同于JMS，提供更加灵活的方式进行JAVA的消息推送</p>
<h2 id="和JMS的区别"><a href="#和JMS的区别" class="headerlink" title="和JMS的区别"></a>和JMS的区别</h2><p>不同于使用“通道”的概念，AMQP使用<code>Exchange</code>作为消息的暂存区域</p>
<blockquote>
<p>Exchange的类型：</p>
<p>Direct ：如果消息的 routing key 与 binding 的 routing key 直接匹配的话，消息将会路由到该队列上； Topic ：如果消息的 routing key 与 binding 的 routing key 符合通配符匹配的话，消息将会路由到该队列上； Headers ：如果消息参数表中的头信息和值都与 bingding 参数表中相匹配，消息将会路由到该队列上； Fanout ：不管消息的 routing key 和参数表的头信息 / 值是什么，消息将会路由到所有队列上。</p>
</blockquote>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>lazytime
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://whitestore.top/2020/07/26/note2/" title="《Spring 实战》解读">https://whitestore.top/2020/07/26/note2/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLzQuMC96aC1DTg=="><i class="fa fa-fw fa-creative-commons"></i>BY-NC</span> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/" rel="tag"># 读书笔记</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/07/26/note1/" rel="prev" title="Neo4j + VIS 数据可视化问题汇总">
      <i class="fa fa-chevron-left"></i> Neo4j + VIS 数据可视化问题汇总
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/07/26/corscaikeng/" rel="next" title="记一次CORS踩坑记录">
      记一次CORS踩坑记录 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#《Spring-实战》解读"><span class="nav-number">1.</span> <span class="nav-text">《Spring 实战》解读</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#基本概念"><span class="nav-number">1.1.</span> <span class="nav-text">基本概念</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Spring应用上下文"><span class="nav-number">1.1.1.</span> <span class="nav-text">Spring应用上下文</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Spring的生命周期"><span class="nav-number">1.1.2.</span> <span class="nav-text">Spring的生命周期</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Spring-模块-（4-0为例）"><span class="nav-number">1.1.3.</span> <span class="nav-text">Spring 模块 （4.0为例）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#版本新特性"><span class="nav-number">1.1.4.</span> <span class="nav-text">版本新特性</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Spring的Bean"><span class="nav-number">1.2.</span> <span class="nav-text">Spring的Bean</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#装配Bean的三种方式："><span class="nav-number">1.2.1.</span> <span class="nav-text">装配Bean的三种方式：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#自动装配"><span class="nav-number">1.2.2.</span> <span class="nav-text">自动装配</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#JAVA配置"><span class="nav-number">1.2.3.</span> <span class="nav-text">JAVA配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#XML配置"><span class="nav-number">1.2.4.</span> <span class="nav-text">XML配置</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#更高级的Bean装配"><span class="nav-number">1.3.</span> <span class="nav-text">更高级的Bean装配</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#profile-Bean"><span class="nav-number">1.3.1.</span> <span class="nav-text">profile Bean</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#激活profile"><span class="nav-number">1.3.2.</span> <span class="nav-text">激活profile</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#条件化-Bean"><span class="nav-number">1.3.3.</span> <span class="nav-text">条件化 Bean</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#标示首选的-bean"><span class="nav-number">1.3.3.1.</span> <span class="nav-text">标示首选的 bean</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#限定自动装配的-bean"><span class="nav-number">1.3.3.2.</span> <span class="nav-text">限定自动装配的 bean</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Bean的作用域"><span class="nav-number">1.4.</span> <span class="nav-text">Bean的作用域</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#运行时注入"><span class="nav-number">1.5.</span> <span class="nav-text">运行时注入</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#SpringMVC"><span class="nav-number">2.</span> <span class="nav-text">SpringMVC</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#DispatcherServelet"><span class="nav-number">2.0.1.</span> <span class="nav-text">DispatcherServelet</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Spring-Web-Flow"><span class="nav-number">2.1.</span> <span class="nav-text">Spring Web Flow</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#是什么："><span class="nav-number">2.2.</span> <span class="nav-text">是什么：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#为什么会有web-Flow"><span class="nav-number">2.3.</span> <span class="nav-text">为什么会有web Flow</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#怎么做："><span class="nav-number">2.4.</span> <span class="nav-text">怎么做：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#总结："><span class="nav-number">2.5.</span> <span class="nav-text">总结：</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Spring-Security"><span class="nav-number">3.</span> <span class="nav-text">Spring Security</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#是什么？"><span class="nav-number">3.1.</span> <span class="nav-text">是什么？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#为什么？"><span class="nav-number">3.2.</span> <span class="nav-text">为什么？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#同类产品比较："><span class="nav-number">3.3.</span> <span class="nav-text">同类产品比较：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#怎么做：-1"><span class="nav-number">3.4.</span> <span class="nav-text">怎么做：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#注意事项："><span class="nav-number">3.5.</span> <span class="nav-text">注意事项：</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#AMQP"><span class="nav-number">4.</span> <span class="nav-text">AMQP</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#是什么？-1"><span class="nav-number">4.1.</span> <span class="nav-text">是什么？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#和JMS的区别"><span class="nav-number">4.2.</span> <span class="nav-text">和JMS的区别</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">阿东</p>
  <div class="site-description" itemprop="description">随遇而安</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">239</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">36</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">37</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2xhenlUaW1lcw==" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;lazyTimes"><i class="fa fa-fw fa-github"></i>GitHub</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="bWFpbHRvOjEwOTc0ODM1MDhAcXEuY29t" title="E-Mail → mailto:1097483508@qq.com"><i class="fa fa-fw fa-envelope"></i>E-Mail</span>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly93d3cuNTJwb2ppZS5jbi9ob21lLnBocD9tb2Q9c3BhY2UmdWlkPTE0OTc3MTgmZG89dGhyZWFkJnZpZXc9bWUmZnJvbT1zcGFjZQ==" title="https:&#x2F;&#x2F;www.52pojie.cn&#x2F;home.php?mod&#x3D;space&amp;uid&#x3D;1497718&amp;do&#x3D;thread&amp;view&#x3D;me&amp;from&#x3D;space">吾爱破解</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9qdWVqaW4uaW0vdXNlci8yOTk5MTIzNDUyNjI2MzY2" title="https:&#x2F;&#x2F;juejin.im&#x2F;user&#x2F;2999123452626366">掘金</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9zZWdtZW50ZmF1bHQuY29tL3UvbGF6eXRpbWVz" title="https:&#x2F;&#x2F;segmentfault.com&#x2F;u&#x2F;lazytimes">思否</span>
        </li>
    </ul>
  </div>

      </div>

      <div class="wechat_OA">
        <span>欢迎关注我的公众号</span>
        <br>
          <!-- 这里添加你的二维码图片 -->
        <img src ="https://adong-picture.oss-cn-shenzhen.aliyuncs.com/adong/wechat_channel.jpg">
      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">阿东</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">2m</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">29:50</span>
</div>
  <div class="powered-by">由 <span class="exturl theme-link" data-url="aHR0cHM6Ly9oZXhvLmlv">Hexo</span> & <span class="exturl theme-link" data-url="aHR0cHM6Ly90aGVtZS1uZXh0Lm9yZw==">NexT.Gemini</span> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : true,
      appId      : 'qMUpEEvBgXaMDD1b0ftgi9xr-gzGzoHsz',
      appKey     : 'UCdfT4Rfih6MO6y8DI4fstf6',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : false,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
